package homework01;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        List<Long> list = new ArrayList<>();
        System.out.print("请输入数列长度:");
        int number = scan.nextInt();
        for (int i = 0; i < number; i++) {
            list.add(fibonacci(i));
        }
        System.out.println(list);
    }

    public static long fibonacci(long number){
        if(number == 0L){
            return 0L;
        }
        if(number == 1L){
            return 1L;
        }
        return fibonacci(number-1L)+fibonacci(number-2L);
    }
}
